﻿//2013.5.13  guxiaoli 
Ext.EventManager.onWindowResize(function () {
	/**
	 * @author LZQ
	 * IE8、Chrome均可使用。 
	 **/
	try{
		Ext.getCmp('split-manual-win').setHeight((50/69)*(Ext.getBody().getViewSize().height));//500 = 690k
        Ext.getCmp('split-manual-win').setWidth(0.625*(Ext.getBody().getViewSize().width));//800 = 1280k
        Ext.getCmp('split-manual-win').setPosition(0.1875*(Ext.getBody().getViewSize().width),(95/690)*(Ext.getBody().getViewSize().height),false);//x : 240 = 1280k，y : 95 = 690k
        Ext.getCmp('split-manual-base-info').setHeight((3/23)*(Ext.getBody().getViewSize().height));//60 = 690k
        Ext.getCmp('split-manual-base-info').setWidth(0.625*(Ext.getBody().getViewSize().width));//60 = 690k
        Ext.getCmp('split-manual-doc-info').setHeight((10/69)*(Ext.getBody().getViewSize().height));//100 = 690k
        Ext.getCmp('split-manual-doc-info').setWidth(0.625*(Ext.getBody().getViewSize().width));//60 = 690k;
        Ext.getCmp('split-manual-left').setHeight((50/69)*(Ext.getBody().getViewSize().height) - (3/23)*(Ext.getBody().getViewSize().height) - (10/69)*(Ext.getBody().getViewSize().height) - 78);
        Ext.getCmp('split-manual-left').setWidth(0.625*(Ext.getBody().getViewSize().width));//60 = 690k
	}catch(error){}
});

Ext.define('HIT.view.DealSplitManualWin', {
    extend: 'Ext.window.Window',
    alias: 'widget.splitmanualwin',
//手工拆分弹出窗口
    height:500,
//    height:Ext.getBody().getViewSize().height - 200,
    width:800,
//    width:Ext.getBody().getViewSize().width - 476,
    overlapHeader: false,
    preventHeader: true,  
    title: Share.T('手工拆分'),
    id:'split-manual-win',
        
    initComponent: function() {
        var me = this;
        this.title = Share.T('手工拆分');                            
        
        Ext.applyIf(me, {
             items: [{
                       xtype:'panel',
                       items:[
						 {
							xtype: 'fieldset',
							title:Share.T('基本信息'),
							height: 60,
							id:'split-manual-base-info',
							layout: {type: 'absolute'},
						    items: [{  //单据编号
						        xtype: 'displayfield',
						        id:'manual-docNo',
						        x: 10,
						        y: 0,
						        fieldLabel: Share.T('单据编号'),
						        value: '',
						        width:250
						    },{  //客户名称
						        xtype: 'displayfield',
						        id:'manual-custName',
						        x: 280,
						        y: 0,
						        fieldLabel: Share.T('客户名称'),
						        value: '',
						        width:500
						    }]
					    },{
						  xtype: 'fieldset',
						  title:Share.T('票据信息'),
 						  height: 100,
 						  id:'split-manual-doc-info',
						  layout: {type: 'absolute'},
				          items: [{
		                	  xtype: 'textfield',
		                	  id: 'manual-amount',
                              fieldLabel: Share.T('不含税金额'),
                              readOnly:true,
                              x:10,
                              y:0,
                              labelWidth:70,
                              width: 250
		                   },{  //不含税金额尾差
				            	xtype: 'displayfield',
		                        x: 270,
		                        y: 0,
		                        fieldLabel: '',
		                        value: '+0.00',
		                        id:'manual-differ-amount',
		                        renderer : renderColor,
		                        width:100
				           },{
			                	xtype: 'textfield',
			                	id: 'manual-tax',
	                            fieldLabel: Share.T('税额'),
	                            readOnly:true,
	                            x:410,
	                            y:0,
	                            labelWidth:60,	                           
	                            width: 250
				           },{  //含税金额尾差
				            	xtype: 'displayfield',
		                        x: 670,
		                        y: 0,
		                        fieldLabel: '',
		                        value: '+0.00',
		                        id:'manual-differ-tax',
	                            renderer : renderColor,
		                        width:100
			                },{
				                xtype: 'textfield',
				                id: 'manual-disamount',
		                        fieldLabel: Share.T('折扣金额'),
		                        readOnly:true,
		                        x:10,
	                            y:35,
	                            labelWidth:70,
		                        width: 250
			                },{  //折扣金额尾差
				            	xtype: 'displayfield',
		                        x: 270,
		                        y: 35,
		                        fieldLabel: '',
		                        value: '+0.00',
		                        id: 'manual-differ-disamount',
	                            renderer : renderColor,
		                        width:100
				            },{
					            xtype: 'textfield',
					            id: 'manual-distax',
			                    fieldLabel: Share.T('折扣税额'),
			                    readOnly:true,
			                    x:410,
	                            y:35,
	                            labelWidth:60,
			                    width: 250
				            },{  //折扣税额尾差
				            	xtype: 'displayfield',
		                        x: 670,
		                        y: 35,
		                        fieldLabel: '',
		                        value: '+0.00',
		                        id: 'manual-differ-distax',
	                            renderer : renderColor,
		                        width:100
					       }]
                       },{
	                       xtype:'grid',
	                       id:'split-manual-left',
	                       width:790,
	                       height:260,
	                       autoScroll:true,
	                       columnLines: true,
	                       title:Share.T("票据明细"),
	                       store:'splitDetailLeft',
	                       columns:[{
	                           xtype : 'rownumberer',
	                           resizable: true,
	                           width : 30
	                       }, {
	                           xtype     : 'gridcolumn',
	                           width     : 40,
	                           align     : 'center',
	                           dataIndex:'groupNum',
							   text: Share.T('分组')
	                       }, {
	                           xtype     : 'gridcolumn',
	                           width     : 100,
	                           align     : 'center',
	                           dataIndex:'GOODS_NAME',
							   text: Share.T('货物名称')
	                       }, {
	                           xtype     : 'gridcolumn',
	                           width     : 80,
	                           text: Share.T('规格'),
	                           align     : 'center',
							   dataIndex:'SPEC'
	                       }, {
	                           xtype     : 'gridcolumn',
	                           width     : 80,
	                           text     : Share.T('数量'),
	                           align     : 'center',
				               dataIndex:'QUANTITY'
	                       },{
	                           xtype     : 'gridcolumn',
	                           align     : 'center',
	                           width     : 80,
	                           text     : Share.T('单价'),
				               dataIndex:'PRICE_CUR'
	                        },{
	                            xtype     : 'gridcolumn',
	                            align     : 'center',
	                            width     : 80,
	                            text: Share.T('金额'),
							    dataIndex:'AMOUNT_CUR'
	                        },{
	                            xtype     : 'gridcolumn',
	                            align     : 'center',
	                            width     : 80,
	                            text     : Share.T('税额'),
				                dataIndex:'TAX_AMOUNT'
	                        },{
	                            xtype     : 'gridcolumn',
	                            align     : 'center',
	                            width     : 80,
	                            text: Share.T('税率'),
							    dataIndex:'TAX_RATE'
	                        },{
	                            xtype     : 'gridcolumn',
	                            align     : 'center',
	                            width     : 80,
	                            text: Share.T('价格方式'),
							    dataIndex:'price_way_desc'
	                        },{
	                            xtype     : 'gridcolumn',
	                            align     : 'center',
	                            width     : 80,
	                            text: Share.T('折扣率'),
							    dataIndex:'DISCOUNT_RATE'
	                        },{
	                            xtype     : 'gridcolumn',
	                            align     : 'center',
	                            width     : 80,
	                            text: Share.T('折扣金额'),
							    dataIndex:'DISCOUNT_SUM'
	                        },{
	                            xtype     : 'gridcolumn',
	                            align     : 'center',
	                            width     : 80,
	                            text: Share.T('折扣税额'),
							    dataIndex:'DISCOUNT_TAX'
	                        }],
	                        viewConfig: {
	                        	enableTextSelection:true
	                        },
	                        selModel: Ext.create('Ext.selection.CheckboxModel', {
	                        	checkOnly: false
	                        })
                        }
                     ]
                   }
                ],
                buttons:[{
                	text:Share.T('分组'),
                	id:'split-menual-group'
                   },{
                	text:Share.T('拆分'),
                	id:'split-menual-split'
                  },{
                	text:Share.T('保存'),
                	id:'split-menual-sure'
                  },{
                	text:Share.T('取消'),
                	handler : function(){
                        this.up('window').close();
                    }
                  }]
         });
        
        function renderColor(value, cellmeta, record, rowIndex, columnIndex, store) { 
        	if(value == 0){
        		return '<span style="color:#666666;">+0.00</span>';
        	}else if(value>0){
        		return "<span style='color:red;'>+" + value + "</span>";
        	}else{
        		return "<span style='color:red;'>" + value + "</span>";
        	}        	
        	
        }          
        me.callParent(arguments);
        
        
    }

});